package com.mail.server.controller;


import com.mail.model.db.SmsFlashPromotionSession;
import com.mail.model.vo.SmsFlashPromotionSessionTimeVo;
import com.mail.server.common.R;
import com.mail.server.service.SmsFlashPromotionSessionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 限时购场次表 前端控制器
 * </p>
 *
 * @author WJZ
 * @since 2022-06-20
 */
@RestController
@RequestMapping("/flashSession")
public class SmsFlashPromotionSessionController {
    @Autowired
    private SmsFlashPromotionSessionService promotionSessionService;

    /**添加场次
     * @param promotionSession
     * @return
     */
    @PostMapping("create")
    public R create(@RequestBody SmsFlashPromotionSessionTimeVo promotionSession) {
        return promotionSessionService.create(promotionSession);
    }

    /**
     * 根据id删除
     *
     * @param id
     * @return
     */
    @PostMapping("/delete/{id}")
    public R delete(@PathVariable Long id) {
        return promotionSessionService.delete(id);
    }

    /**获取全部场次
     * @return
     */
    @GetMapping("list")
    public R list() {
        return promotionSessionService.list();
    }

    /**获取全部可选场次及其数量
     * @param flashPromotionId
     * @return
     */
    @GetMapping("/selectList")
    public R selectList(@RequestParam(value = "flashPromotionId",required = false)Long flashPromotionId){
return promotionSessionService.selectList(flashPromotionId);
    }

    /**修改启用状态
     * @param id
     * @param status
     * @return
     */
    @PostMapping("update/status/{id}")
    public R updateStatus (@PathVariable Long id,@RequestParam("status")Long status ){
        return promotionSessionService.updateStatus(id,status);
    }

    /**修改场次
     * @param id
     * @param session
     * @return
     */
    @PostMapping("/update/{id}")
    public R update(@PathVariable Long id,@RequestBody SmsFlashPromotionSessionTimeVo session){
        return promotionSessionService.update(id,session);
    }
    @GetMapping("{id}")
    public R getFlashSession(@PathVariable Long id){
        return promotionSessionService.getFlashSession(id);
    }

}
